/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hate;

import apunte.Apunte;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.LinkedList;
import javax.swing.JOptionPane;

/**
 *
 * @author martinLequerica
 */
public class EntradaSalida {

    private static final char[] HEXADECIMAL = {'0', '1', '2', '3',
        '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
//hace hash

    public String hash(String stringToHash) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] bytes = md.digest(stringToHash.getBytes());
            StringBuilder sb = new StringBuilder(2 * bytes.length);
            for (int i = 0; i < bytes.length; i++) {
                int low = (int) (bytes[i] & 0x0f);
                int high = (int) ((bytes[i] & 0xf0) >> 4);
                sb.append(HEXADECIMAL[high]);
                sb.append(HEXADECIMAL[low]);
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            //exception handling goes here
            return null;
        }
    }
    private File f;
    private ObjectOutputStream salida;
    private ObjectInputStream entrada;

    public Object leerObjeto(File f) throws IOException, ClassNotFoundException {

        entrada = new ObjectInputStream(new FileInputStream(f));
        Object o = new Object();
        o = (Object) entrada.readObject();

        return o;


    }

    public void guardarObjeto(LinkedList<Apunte> lla, File f) throws IOException {

        salida = new ObjectOutputStream(new FileOutputStream(f));


        
        



    }
}
